package com.example.demo.controller;
/**
 * @Author Justice
 * @Date 2019/4/8 16:17
 * @Version 1.0
 */

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.eo.UserInfo;
import com.example.demo.mapper.UserInfoMapper;
import com.example.demo.service.BaseInterface;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class DbController {


  @Resource
  private JdbcTemplate jdbcTemplate;
  @Resource
  private UserInfoMapper userInfoMapper;
  @Resource
  private BaseInterface baseInterface;
   
  @RequestMapping("/u")
  public List<Map<String, Object>> getDbType(){
    String sql = "select * from sys_user";
    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
    return list;
  }

  @RequestMapping("/m")
  public Object mlist(){
    return JSON.toJSONString(userInfoMapper.selectList(null));
  }

  @RequestMapping("/n")
  public Object queryM(){
    return JSON.toJSONString(
            userInfoMapper.selectList(
                    Wrappers.<UserInfo>lambdaQuery()
                    .select(UserInfo::getBalance,UserInfo::getId)
                    .eq(UserInfo::getBalance,0)
            )

    );
  }

  @RequestMapping("/b")
  public Object queryB(){
    return baseInterface.getStr();
  }

}